{%include file="header.html"%}
<form action="{%$formAction%}" method="POST" {%if $is_validator%} id="adminform" onsubmit="return Validator.Validate(this)" {%/if%}>
<script type="text/javascript">
<!--
    function select_acl(top_id, t){
        var type	=	$(t).attr('checked');
        if(!type){
            type=false;
        }
        if(top_id == 169){
            $("input[name='acl_id[]']").each(function(){
                $(this).attr('checked',type);
            });
        }else{
            $(".level"+top_id).each(function(){
                $(this).attr('checked',type);
            });
        }
    }
//-->
</script>
<div style="padding:10px;">
<fieldset>
	<legend>{%$systemLang.authorizedUserGroup%}</legend>
    <ul class="aclList">
    {%foreach from=$userGroup item="level_1" %}   
    <li>
        <input type="checkbox" name="group_id[]"  value="{%$level_1.group_id%}" {%if $level_1.group_id == $group_id%} readonly='readonly' CHECKED="true" {%else%} readonly=TRUE {%/if%}>{%$level_1.group_value%}
    </li>
    {%/foreach%}
    </ul>
</fieldset>
<div>
{%foreach from=$acl item="level_1"%}
<fieldset>
	<legend>
        <input type="checkbox" name="acl_id[]" onclick="select_acl({%$level_1.acl_id%},this)" value="{%$level_1.acl_id%}" id="acl_{%$level_1.acl_id%}" {%if $level_1.acl_id|in_array:$myacl%} CHECKED="true"{%/if%}>{%$level_1.acl_name%}
    </legend>
        {%foreach from=$acl_child[$level_1.acl_id] item="level_2"%}
            <fieldset>
                <legend>
                    <input type="checkbox" name="acl_id[]" onclick="select_acl({%$level_2.acl_id%},this)" value="{%$level_2.acl_id%}" id="acl_{%$level_1.acl_id%}_{%$level_2.acl_id%}" {%if $level_2.acl_id|in_array:$myacl%} CHECKED="true"{%/if%}>{%$level_2.acl_name%}
                </legend>
                <ul class="aclList">
                        {%foreach from=$acl_child[$level_2.acl_id] item="level_3"%}
                        <li>
                            <input type="checkbox" name="acl_id[]" class="level{%$level_2.acl_id%}" value="{%$level_3.acl_id%}" {%if $level_3.acl_id|in_array:$myacl%} CHECKED="true" {%/if%} id="acl_{%$level_1.acl_id%}_{%$level_2.acl_id%}_{%$level_3.acl_id%}">{%$level_3.acl_name%}
                        {%/foreach%}
                </ul>
           </fieldset>
        {%/foreach%}
</fieldset>
{%/foreach%}
</div>
</div>
<div style="padding:5px; clear:both;">
<input type="submit" value="{%$systemLang.authorized%}" name="submit" class="button" />
</div>
</form>